//
//  BoHuiReasonAlertView.m
//  DriverClient
//
//  Created by 吕晶 on 2020/9/10.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "BoHuiReasonAlertView.h"

@interface BoHuiReasonAlertView ()

@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UILabel *contentLab;
@property (nonatomic, strong) UIView *bgView;

@end

@implementation BoHuiReasonAlertView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.frame = CGRectMake(0, 0, ScreenW, ScreenH);
        self.backgroundColor = HexColorA(0x000000, 0.5);
        [self configUI];
    }
    return self;
}

- (void)configUI {
    self.bgView = [[UIView alloc] initWithFrame:CGRectMake(30, (ScreenH - 243) * 0.5, ScreenW - 60, 243)];
    self.bgView.backgroundColor = HexColor(0xffffff);
    self.bgView.layer.masksToBounds = YES;
    self.bgView.layer.cornerRadius = 6;
    [self addSubview:self.bgView];
    
    UIImageView *iconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 25, 16, 16)];
    iconImgView.image = [UIImage imageNamed:@"zhuangChe_notice"];
    [self.bgView addSubview:iconImgView];
    
    UILabel *lab = [UILabel new];
    lab.textColor = HexColor(0x2B2C44);
    lab.font = BoldFontOfSize(18);
    lab.text = @"驳回原因";
    [lab sizeToFit];
    lab.nim_left = iconImgView.nim_right + 5;
    lab.nim_centerY = iconImgView.nim_centerY;
    [self.bgView addSubview:lab];
    
    self.timeLab = [[UILabel alloc] initWithFrame:CGRectMake(iconImgView.nim_left, iconImgView.nim_bottom + 9, self.bgView.nim_width - 40, 17)];
    self.timeLab.textColor = HexColor(0x585974);
    self.timeLab.font = [UIFont systemFontOfSize:16];
    [self.bgView addSubview:self.timeLab];
    
    self.contentLab = [[UILabel alloc] initWithFrame:CGRectMake(iconImgView.nim_left, self.timeLab.nim_bottom + 10, self.bgView.nim_width - 40, 0)];
    self.contentLab.textColor = HexColor(0x9C9DB3);
    self.contentLab.font = [UIFont systemFontOfSize:16];
    [self.bgView addSubview:self.contentLab];
    
    UIButton *cancleBtn = [UIButton new];
    cancleBtn.nim_left = 0;
    cancleBtn.nim_width = self.bgView.nim_width;
    cancleBtn.nim_height = 50;
    cancleBtn.nim_top = self.bgView.nim_height - cancleBtn.nim_height;
    [cancleBtn setTitle:@"关闭" forState:0];
    [cancleBtn setTitleColor:Color_ThemeColor forState:0];
    cancleBtn.titleLabel.font = BoldFontOfSize(16);
    [cancleBtn addTarget:self action:@selector(disMissView) forControlEvents:UIControlEventTouchUpInside];
    [self.bgView addSubview:cancleBtn];
    
    UILabel *line1 = [[UILabel alloc] initWithFrame:CGRectMake(0, cancleBtn.nim_top - 1, self.bgView.nim_width, 1)];
    line1.backgroundColor = Color_backgroundColor;
    [self.bgView addSubview:line1];
}

-(void)setTimeStr:(NSString *)timeStr {
    _timeStr = timeStr;
    self.timeLab.text = timeStr;
}

-(void)setReasonStr:(NSString *)reasonStr {
    _reasonStr = reasonStr;
    self.contentLab.text = reasonStr;
    [self.contentLab sizeToFit];
}

- (void)showInView:(UIView *)view {
    if (!view) {
        return;
    }
    [view addSubview:self];
    [view addSubview:self.bgView];
}

- (void)disMissView {
    [self removeFromSuperview];
    [self.bgView removeFromSuperview];
}

@end
